
#ifndef UD_DBDICT_H
#define UD_DBDICT_H

#include "zdbmain.h"

#pragma pack(push, 8)

class UcDbImpDictionary;
class UcString;

class ZSOFT_NO_VTABLE UcDbDictionaryIterator: public UcRxObject
{
public:
    UCRX_DECLARE_MEMBERS(UcDbDictionaryIterator);
    virtual ~UcDbDictionaryIterator() {}

    virtual const ZTCHAR*      name       () const = 0;

    virtual Ucad::ErrorStatus getObject  (UcDbObject*&   pObject,
                                          UcDb::OpenMode mode) = 0;
    virtual UcDbObjectId      objectId   () const = 0;

    virtual bool              done       () const = 0;
    virtual bool              next       () = 0;
    virtual bool              setPosition(UcDbObjectId objId) = 0;

protected:
    UcDbDictionaryIterator() {}
};

class UcDbDictionary: public UcDbObject
{
public:
    UCDB_DECLARE_MEMBERS(UcDbDictionary);
    UcDbDictionary();
    virtual ~UcDbDictionary();

    Ucad::ErrorStatus getAt(const ZTCHAR*   entryName,
                            UcDbObject*&   entryObj,
                            UcDb::OpenMode mode) const;
    Ucad::ErrorStatus getAt(const ZTCHAR*   entryName,
                            UcDbObjectId&  entryObj) const;
    Ucad::ErrorStatus nameAt(UcDbObjectId objId,
                             ZTCHAR*&      name) const;
    Ucad::ErrorStatus nameAt(UcDbObjectId objId,
                             UcString &   name) const;
    bool              has       (const ZTCHAR*  entryName) const;
    bool              has       (UcDbObjectId objId) const;
    ZSoft::UInt32     numEntries() const;

    Ucad::ErrorStatus remove(const ZTCHAR *  key);
    Ucad::ErrorStatus remove(const ZTCHAR *  key,
                             UcDbObjectId& returnId);
    Ucad::ErrorStatus remove(UcDbObjectId  objId);

    bool              setName(const ZTCHAR*   oldName,
                              const ZTCHAR*   newName);
    Ucad::ErrorStatus setAt  (const ZTCHAR*   srchKey,
                              UcDbObject*   newValue,
                              UcDbObjectId& retObjId);

    bool              isTreatElementsAsHard () const;
    void              setTreatElementsAsHard(bool doIt);

	UcDbDictionaryIterator* newIterator() const;

    virtual Ucad::ErrorStatus subErase     (ZSoft::Boolean pErasing
                                                = ZSoft::kTrue);
    virtual Ucad::ErrorStatus dwgInFields  (UcDbDwgFiler* pFiler);
    virtual Ucad::ErrorStatus dwgOutFields (UcDbDwgFiler* pFiler) const;
    virtual Ucad::ErrorStatus dxfInFields  (UcDbDxfFiler* pFiler);
    virtual Ucad::ErrorStatus dxfOutFields (UcDbDxfFiler* pFiler) const;

    virtual UcDb::DuplicateRecordCloning mergeStyle() const;
    virtual void  setMergeStyle(UcDb::DuplicateRecordCloning style);

    virtual void goodbye(const UcDbObject* pObject);
    virtual void erased (const UcDbObject* pObject,
                         ZSoft::Boolean pErasing = ZSoft::kTrue);

    virtual Ucad::ErrorStatus decomposeForSave(
                                  UcDb::UcDbDwgVersion ver,
                                  UcDbObject*&         replaceObj,
                                  UcDbObjectId&        replaceId,
                                  ZSoft::Boolean&      exchangeXData);

    virtual Ucad::ErrorStatus getClassID(CLSID* pClsid) const;
};

#pragma pack(pop)

#endif
